package commRedisRpc

import (
	"encoding/json"
	commRedisRpc "gitee.com/fierce_wolf/go-fox-edge-common/commRedisList"
)

type redisListManagerClientRequest struct {
	redisList commRedisRpc.RedisListService
}

func (e *redisListManagerClientRequest) PushRequest(uuid string, uri string, method string, data interface{}) error {
	requestVO := &RestFulRequestVO{}
	requestVO.Uuid = uuid
	requestVO.Uri = uri
	requestVO.Method = method
	requestVO.Data = data

	return e.Push(requestVO)
}

func (e *redisListManagerClientRequest) Push(value *RestFulRequestVO) error {
	mainKey := "fox.edge.list:manager:restful:message:request"

	code, err := json.Marshal(value)
	if err != nil {
		return err
	}

	jsn := string(code)
	err = e.redisList.KPush(mainKey, jsn)
	if err != nil {
		return err
	}
	return nil
}
